Data Read In

CSLAP<-read.csv("CSLAP_Dataset_09232019.csv", header=TRUE, stringsAsFactors = F)
CSLAP$Sample_Year<-as.factor(CSLAP$Sample_Year)
CSLAP$Sample_Month<-as.factor(CSLAP$Sample_Month)

#Create TN:TP column 
CSLAP$TN_TP<-(CSLAP$TN_mg.L+.01)/(CSLAP$TP_mg.L+.01)

#Read in and merge %ag 
Ag<-read.csv("Percent Ag Cover.csv", na.strings=c("", " "))
CSLAP<-merge(CSLAP, Ag, by="Lake_Name", all.x=TRUE)

#Split by `Info_Type`
OWCSLAP<-CSLAP[CSLAP$Info_Type == "OW",]
BSCSLAP<-CSLAP[CSLAP$Info_Type == "BS",]
SBCSLAP<-CSLAP[CSLAP$Info_Type == "SB",]
noSBCSLAP<-CSLAP[CSLAP$Info_Type != "SB",]

redCSLAP<-read.csv("redCSLAP.csv")
names(redCSLAP)[names(redCSLAP) == "Lake_Name.x"] <- "Lake_Name"
names(redCSLAP)[names(redCSLAP) == "Dreissenids.x"] <- "Dreissenids"
redCSLAP$Sample_Year<-as.factor(redCSLAP$Sample_Year)
redCSLAP$Sample_Month<-as.factor(redCSLAP$Sample_Month)

#Create TN:TP column 
redCSLAP$TN_TP<-(redCSLAP$TN_mg.L+.01)/(redCSLAP$TP_mg.L+.01)

#Merge %ag
redCSLAP<-merge(redCSLAP, Ag, by="Lake_Name", all.x=TRUE)

#Split by `Info_Type`
redOWCSLAP<-redCSLAP[redCSLAP$Info_Type == "OW",]
redBSCSLAP<-redCSLAP[redCSLAP$Info_Type == "BS",]
redSBCSLAP<-redCSLAP[redCSLAP$Info_Type == "SB",]
rednoSBCSLAP<-redCSLAP[redCSLAP$Info_Type != "SB",]

Global Dataset

Open Water TN:TP - lmer()

TNTP<-lmer(log(TN_TP+.01) ~ Dreissenids + log(CA.SA) + log(Mean_Depth_m) + Percent_Ag +  (1|Sample_Year) + (1|Sample_Month) + (1|LakeID) + (1|Sample_Year:LakeID), data=OWCSLAP)

summary(TNTP)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(TN_TP + 0.01) ~ Dreissenids + log(CA.SA) + log(Mean_Depth_m) +  
##     Percent_Ag + (1 | Sample_Year) + (1 | Sample_Month) + (1 |  
##     LakeID) + (1 | Sample_Year:LakeID)
##    Data: OWCSLAP
## 
## REML criterion at convergence: 3172.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -8.2481 -0.4424  0.0144  0.4864  8.0077 
## 
## Random effects:
##  Groups             Name        Variance Std.Dev.
##  Sample_Year:LakeID (Intercept) 0.032401 0.18000 
##  LakeID             (Intercept) 0.036200 0.19026 
##  Sample_Month       (Intercept) 0.001351 0.03676 
##  Sample_Year        (Intercept) 0.008238 0.09076 
##  Residual                       0.165055 0.40627 
## Number of obs: 2624, groups:  
## Sample_Year:LakeID, 344; LakeID, 68; Sample_Month, 6; Sample_Year, 6
## 
## Fixed effects:
##                       Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)           2.703403   0.130632 80.476010  20.695   <2e-16 ***
## DreissenidsUninvaded -0.061902   0.082491 94.133562  -0.750   0.4549    
## log(CA.SA)            0.044379   0.026535 62.225626   1.673   0.0994 .  
## log(Mean_Depth_m)     0.001304   0.040636 65.427991   0.032   0.9745    
## Percent_Ag            0.007264   0.002236 67.770001   3.249   0.0018 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) DrssnU l(CA.S l(M_D_
## DrssndsUnnv -0.660                     
## log(CA.SA)  -0.455  0.043              
## lg(Mn_Dpt_) -0.501  0.071 -0.043       
## Percent_Ag  -0.256  0.314 -0.047 -0.084
plot(TNTP)

qqPlot(resid(TNTP))

## 1395 3666 
##  711 1949

Open Water TN:TP - glmer()

TNTP2<-glmer(TN_TP ~ Dreissenids + log(CA.SA) + log(Mean_Depth_m) + Percent_Ag +  (1|LakeID) + (1|Sample_Year:LakeID), data=OWCSLAP, family=Gamma(link="log"))
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.0016124 (tol = 0.001, component 1)
summary(TNTP2)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: Gamma  ( log )
## Formula: TN_TP ~ Dreissenids + log(CA.SA) + log(Mean_Depth_m) + Percent_Ag +  
##     (1 | LakeID) + (1 | Sample_Year:LakeID)
##    Data: OWCSLAP
## 
##      AIC      BIC   logLik deviance df.resid 
##    17962    18009    -8973    17946     2616 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.8001 -0.4237 -0.0833  0.2894 16.2155 
## 
## Random effects:
##  Groups             Name        Variance Std.Dev.
##  Sample_Year:LakeID (Intercept) 0.08084  0.2843  
##  LakeID             (Intercept) 0.01804  0.1343  
##  Residual                       0.29233  0.5407  
## Number of obs: 2624, groups:  Sample_Year:LakeID, 344; LakeID, 68
## 
## Fixed effects:
##                       Estimate Std. Error t value Pr(>|z|)    
## (Intercept)           2.790367   0.156455  17.835   <2e-16 ***
## DreissenidsUninvaded -0.065651   0.106021  -0.619   0.5358    
## log(CA.SA)            0.037277   0.033027   1.129   0.2590    
## log(Mean_Depth_m)     0.005015   0.050622   0.099   0.9211    
## Percent_Ag            0.005859   0.002786   2.103   0.0355 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) DrssnU l(CA.S l(M_D_
## DrssndsUnnv -0.702                     
## log(CA.SA)  -0.470  0.033              
## lg(Mn_Dpt_) -0.528  0.076 -0.036       
## Percent_Ag  -0.271  0.316 -0.052 -0.081
## convergence code: 0
## Model failed to converge with max|grad| = 0.0016124 (tol = 0.001, component 1)
plot(TNTP2)

qqPlot(resid(TNTP2))

## 3666  684 
## 1949  343
simTNTP  <-  simulateResiduals(TNTP)
## Warning in checkModel(fittedModel): DHARMa: fittedModel not in class of
## supported models. Absolutely no guarantee that this will work!
## Model family was recognized or set as continuous, but duplicate values were detected in the response. Consider if you are fitting an appropriate model.
plotSimulatedResiduals(simTNTP) 
## plotSimulatedResiduals is deprecated, switch your code to using the plot function

Open Water Chlorophyll-a

-Sample_Year and Sample_Month removed for having low variance

Chl<-lmer(log(Extracted_Chl.a_ug.L+1) ~ Dreissenids + log(CA.SA) + Mean_Depth_m + Percent_Ag  + (1|LakeID) + (1|Sample_Year:LakeID), data=OWCSLAP)

summary(Chl)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: 
## log(Extracted_Chl.a_ug.L + 1) ~ Dreissenids + log(CA.SA) + Mean_Depth_m +  
##     Percent_Ag + (1 | LakeID) + (1 | Sample_Year:LakeID)
##    Data: OWCSLAP
## 
## REML criterion at convergence: 3594.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.7666 -0.5667 -0.0549  0.4966  5.7200 
## 
## Random effects:
##  Groups             Name        Variance Std.Dev.
##  Sample_Year:LakeID (Intercept) 0.02834  0.1683  
##  LakeID             (Intercept) 0.08726  0.2954  
##  Residual                       0.19763  0.4446  
## Number of obs: 2606, groups:  Sample_Year:LakeID, 344; LakeID, 68
## 
## Fixed effects:
##                        Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)            1.280163   0.150389  84.608941   8.512 5.41e-13 ***
## DreissenidsUninvaded   0.046105   0.107739 125.583342   0.428  0.66943    
## log(CA.SA)             0.050864   0.039282  58.680926   1.295  0.20045    
## Mean_Depth_m          -0.034545   0.010296  60.160977  -3.355  0.00138 ** 
## Percent_Ag             0.003242   0.003174  63.412744   1.021  0.31100    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) DrssnU l(CA.S Mn_Dp_
## DrssndsUnnv -0.713                     
## log(CA.SA)  -0.522  0.040              
## Mean_Dpth_m -0.290  0.008 -0.202       
## Percent_Ag  -0.325  0.291 -0.055 -0.012
plot(Chl)

qqPlot(resid(Chl))

## 2429 1225 
## 1231  612

Open Water Secchi Depth

-Sample_Year and Sample_Month removed for having low variance

Secchi <- lmer(log(Secchi_Depth_m) ~ Dreissenids + log(CA.SA) + Mean_Depth_m + Percent_Ag + (1|LakeID) + (1|Sample_Year:LakeID), data=OWCSLAP)

summary(Secchi)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(Secchi_Depth_m) ~ Dreissenids + log(CA.SA) + Mean_Depth_m +  
##     Percent_Ag + (1 | LakeID) + (1 | Sample_Year:LakeID)
##    Data: OWCSLAP
## 
## REML criterion at convergence: -267.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.9556 -0.5342  0.0136  0.5662  4.8113 
## 
## Random effects:
##  Groups             Name        Variance Std.Dev.
##  Sample_Year:LakeID (Intercept) 0.01263  0.1124  
##  LakeID             (Intercept) 0.08874  0.2979  
##  Residual                       0.04109  0.2027  
## Number of obs: 2601, groups:  Sample_Year:LakeID, 344; LakeID, 68
## 
## Fixed effects:
##                        Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)            1.390407   0.130971 104.194792  10.616  < 2e-16 ***
## DreissenidsUninvaded  -0.111388   0.082310 255.965715  -1.353   0.1772    
## log(CA.SA)            -0.100121   0.038135  63.183212  -2.625   0.0108 *  
## Mean_Depth_m           0.045664   0.009951  63.697069   4.589 2.15e-05 ***
## Percent_Ag            -0.001281   0.003028  68.441407  -0.423   0.6735    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) DrssnU l(CA.S Mn_Dp_
## DrssndsUnnv -0.625                     
## log(CA.SA)  -0.571  0.031              
## Mean_Dpth_m -0.320  0.004 -0.200       
## Percent_Ag  -0.275  0.233 -0.063 -0.017
plot(Secchi)

qqPlot(resid(Secchi))

## 4614 4673 
## 2422 2451

Open Water True Color

-Gamma model with no random effects comes out great, Gamma model with random effects much worse

-Tried log-transforming True Color, but that made residuals and qqPlot worse

-Sample_Year and Sample_Month removed for having low variance

OWTC<-lmer(True_Color_PTU ~ Dreissenids + log(CA.SA) + log(Mean_Depth_m) + Percent_Ag + (1|LakeID) + (1|Sample_Year:LakeID), data=OWCSLAP)

summary(OWTC)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: True_Color_PTU ~ Dreissenids + log(CA.SA) + log(Mean_Depth_m) +  
##     Percent_Ag + (1 | LakeID) + (1 | Sample_Year:LakeID)
##    Data: OWCSLAP
## 
## REML criterion at convergence: 16659.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.6963 -0.4677 -0.0608  0.3894  9.8534 
## 
## Random effects:
##  Groups             Name        Variance Std.Dev.
##  Sample_Year:LakeID (Intercept) 29.40    5.422   
##  LakeID             (Intercept) 54.34    7.371   
##  Residual                       23.12    4.808   
## Number of obs: 2627, groups:  Sample_Year:LakeID, 345; LakeID, 68
## 
## Fixed effects:
##                        Estimate Std. Error         df t value Pr(>|t|)   
## (Intercept)           11.214842   4.243693  82.755937   2.643  0.00983 **
## DreissenidsUninvaded   5.835025   2.660055 133.684968   2.194  0.02999 * 
## log(CA.SA)             2.457018   0.958047  59.815013   2.565  0.01286 * 
## log(Mean_Depth_m)     -4.013096   1.456228  61.390628  -2.756  0.00770 **
## Percent_Ag            -0.001866   0.079283  64.703351  -0.024  0.98129   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) DrssnU l(CA.S l(M_D_
## DrssndsUnnv -0.651                     
## log(CA.SA)  -0.501  0.038              
## lg(Mn_Dpt_) -0.544  0.059 -0.036       
## Percent_Ag  -0.231  0.280 -0.056 -0.096
plot(OWTC)

qqPlot(resid(OWTC))

## 3281 4510 
## 1695 2395

Shoreline Bloom Chlorophyll a

-update 03/08 boundary (singular) fit Removed random effect of Sample_Year with ~0.00 variance to resolve warning.

SBChl<-lmer(log(ESF_Chl.a_ug.L) ~ Dreissenids + log(CA.SA) + Mean_Depth_m + Percent_Ag + (1|Sample_Month) + (1|LakeID) , data=SBCSLAP)

summary(SBChl)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(ESF_Chl.a_ug.L) ~ Dreissenids + log(CA.SA) + Mean_Depth_m +  
##     Percent_Ag + (1 | Sample_Month) + (1 | LakeID)
##    Data: SBCSLAP
## 
## REML criterion at convergence: 992.8
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.92500 -0.60916  0.06149  0.61850  2.22800 
## 
## Random effects:
##  Groups       Name        Variance Std.Dev.
##  LakeID       (Intercept) 2.18554  1.4784  
##  Sample_Month (Intercept) 0.08275  0.2877  
##  Residual                 4.40087  2.0978  
## Number of obs: 219, groups:  LakeID, 42; Sample_Month, 6
## 
## Fixed effects:
##                      Estimate Std. Error       df t value Pr(>|t|)   
## (Intercept)           5.24989    1.49081 38.13995   3.522  0.00113 **
## DreissenidsUninvaded -0.28234    0.97251 43.86278  -0.290  0.77294   
## log(CA.SA)            0.28546    0.33226 34.64026   0.859  0.39617   
## Mean_Depth_m         -0.12619    0.11900 30.98357  -1.060  0.29717   
## Percent_Ag            0.03388    0.02595 35.42128   1.306  0.20007   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) DrssnU l(CA.S Mn_Dp_
## DrssndsUnnv -0.744                     
## log(CA.SA)  -0.487  0.063              
## Mean_Dpth_m -0.485  0.101  0.001       
## Percent_Ag  -0.462  0.513 -0.074  0.001
plot(SBChl)

qqPlot(resid(SBChl))

##  614 4342 
##   44  195

Shoreline Bloom Microcystin

-update 03/08 boundary (singular) fit Removed random effect of Sample_Month with 0.00 variance to resolve warning.

-update 06/05 adding continuous variable of TN:TP as a fixed effect

-removed (LakeID:Sample_Year) because low variance

Extract average TN:TP values for each lake and year

#Extracting average annual TP for each lake 
library(plyr)
avgTNTP<-ddply(OWCSLAP, c("LakeID", "Sample_Year"), summarize, 
             Mean = mean(TN_TP, na.rm=TRUE))
colnames(avgTNTP)[colnames(avgTNTP)=="Mean"] <- "TN_TP"

#Merge these values to the SBCSLAP df 
SBCSLAP<-SBCSLAP[,c(1:44, 46)]
SBCSLAP<-merge(SBCSLAP, avgTNTP, by=c("LakeID", "Sample_Year"), all.x=TRUE, all.y=FALSE)
SBmicro<-lmer(log(ESF_Microcystin_ug.L) ~ Dreissenids + TN_TP + log(CA.SA) + Mean_Depth_m + Percent_Ag + (1|Sample_Year) + (1|LakeID), data=SBCSLAP)

summary(SBmicro)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(ESF_Microcystin_ug.L) ~ Dreissenids + TN_TP + log(CA.SA) +  
##     Mean_Depth_m + Percent_Ag + (1 | Sample_Year) + (1 | LakeID)
##    Data: SBCSLAP
## 
## REML criterion at convergence: 175.4
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.30446 -0.54677  0.03348  0.52972  1.59541 
## 
## Random effects:
##  Groups      Name        Variance Std.Dev.
##  LakeID      (Intercept) 2.316    1.522   
##  Sample_Year (Intercept) 5.950    2.439   
##  Residual                2.290    1.513   
## Number of obs: 43, groups:  LakeID, 7; Sample_Year, 6
## 
## Fixed effects:
##                      Estimate Std. Error       df t value Pr(>|t|)
## (Intercept)          17.19767    7.12147  2.01423   2.415    0.136
## DreissenidsUninvaded -1.87235    2.42891  1.02284  -0.771    0.580
## TN_TP                -0.05043    0.05720  4.77410  -0.882    0.420
## log(CA.SA)           -3.12110    2.31130  1.82983  -1.350    0.320
## Mean_Depth_m         -0.77147    0.46167  1.53193  -1.671    0.273
## Percent_Ag           -0.06223    0.07037  1.53839  -0.884    0.493
## 
## Correlation of Fixed Effects:
##             (Intr) DrssnU TN_TP  l(CA.S Mn_Dp_
## DrssndsUnnv -0.275                            
## TN_TP       -0.153  0.006                     
## log(CA.SA)  -0.839 -0.177  0.011              
## Mean_Dpth_m -0.769  0.154 -0.065  0.593       
## Percent_Ag  -0.633  0.575 -0.283  0.377  0.462
plot(SBmicro)

qqPlot(resid(SBmicro))

## 60 36 
## 23 16

Reduced Dataset

Open Water TN:TP

-Sample_Month and Sample_Year removed for low variance

redTNTP<-glmer(TN_TP ~ Dreissenids + Percent_Ag +  (1|LakeID) + (1|Sample_Year:LakeID), data=redOWCSLAP, family=Gamma(link="log"))

summary(redTNTP)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: Gamma  ( log )
## Formula: 
## TN_TP ~ Dreissenids + Percent_Ag + (1 | LakeID) + (1 | Sample_Year:LakeID)
##    Data: redOWCSLAP
## 
##      AIC      BIC   logLik deviance df.resid 
##   4223.4   4250.0  -2105.7   4211.4      612 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.1584 -0.4826 -0.0688  0.3196 11.4263 
## 
## Random effects:
##  Groups             Name        Variance Std.Dev.
##  Sample_Year:LakeID (Intercept) 0.05114  0.2261  
##  LakeID             (Intercept) 0.02977  0.1725  
##  Residual                       0.20316  0.4507  
## Number of obs: 618, groups:  Sample_Year:LakeID, 80; LakeID, 16
## 
## Fixed effects:
##                      Estimate Std. Error t value Pr(>|z|)    
## (Intercept)          2.717645   0.172302  15.773   <2e-16 ***
## DreissenidsUninvaded 0.045465   0.170140   0.267   0.7893    
## Percent_Ag           0.015466   0.006712   2.304   0.0212 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) DrssnU
## DrssndsUnnv -0.730       
## Percent_Ag  -0.721  0.427
plot(redTNTP)

qqPlot(resid(redTNTP))

## 552 350 
## 281 158

Open Water Chlorophyll-a

-Sample_Year and Sample_Month removed for having low variance

redChl<-lmer(log(Extracted_Chl.a_ug.L+1) ~ Dreissenids + Percent_Ag  + (1|LakeID) + (1|Sample_Year:LakeID), data=redOWCSLAP)

summary(redChl)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(Extracted_Chl.a_ug.L + 1) ~ Dreissenids + Percent_Ag + (1 |  
##     LakeID) + (1 | Sample_Year:LakeID)
##    Data: redOWCSLAP
## 
## REML criterion at convergence: 703
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.1216 -0.6131 -0.0398  0.5263  5.7090 
## 
## Random effects:
##  Groups             Name        Variance Std.Dev.
##  Sample_Year:LakeID (Intercept) 0.02612  0.1616  
##  LakeID             (Intercept) 0.02947  0.1717  
##  Residual                       0.15418  0.3927  
## Number of obs: 619, groups:  Sample_Year:LakeID, 81; LakeID, 16
## 
## Fixed effects:
##                       Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)           1.209719   0.097822 14.514124  12.367  4.2e-09 ***
## DreissenidsUninvaded -0.035804   0.098511 21.579328  -0.363    0.720    
## Percent_Ag           -0.002540   0.003759 11.382668  -0.676    0.513    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) DrssnU
## DrssndsUnnv -0.741       
## Percent_Ag  -0.727  0.444
plot(redChl)

qqPlot(resid(redChl))

## 391 626 
## 175 314

Open Water Secchi Depth

-Sample_Year and Sample_Month removed for having low variance

redSecchi <- lmer(log(Secchi_Depth_m) ~ Dreissenids + Percent_Ag + (1|LakeID) + (1|Sample_Year:LakeID), data=redOWCSLAP)

summary(redSecchi)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(Secchi_Depth_m) ~ Dreissenids + Percent_Ag + (1 | LakeID) +  
##     (1 | Sample_Year:LakeID)
##    Data: redOWCSLAP
## 
## REML criterion at convergence: -48.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.7424 -0.5271 -0.0301  0.5525  3.7536 
## 
## Random effects:
##  Groups             Name        Variance Std.Dev.
##  Sample_Year:LakeID (Intercept) 0.02067  0.1438  
##  LakeID             (Intercept) 0.09194  0.3032  
##  Residual                       0.04004  0.2001  
## Number of obs: 620, groups:  Sample_Year:LakeID, 81; LakeID, 16
## 
## Fixed effects:
##                       Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)           1.441125   0.130482 23.215997  11.045 1.02e-10 ***
## DreissenidsUninvaded -0.137430   0.106535 69.776663  -1.290    0.201    
## Percent_Ag           -0.002111   0.005635 15.373851  -0.375    0.713    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) DrssnU
## DrssndsUnnv -0.607       
## Percent_Ag  -0.693  0.324
plot(redSecchi)

qqPlot(resid(redSecchi))

## 1078  105 
##  520   56

Open Water True Color

-Sample_Year and Sample_Month removed for having low variance

-log-transforming True Color does not improve fit

redOWTC<-lmer(True_Color_PTU ~ Dreissenids + Percent_Ag + (1|LakeID) + (1|Sample_Year:LakeID), data=redOWCSLAP)

summary(redOWTC)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: True_Color_PTU ~ Dreissenids + Percent_Ag + (1 | LakeID) + (1 |  
##     Sample_Year:LakeID)
##    Data: redOWCSLAP
## 
## REML criterion at convergence: 3922.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.9656 -0.4734 -0.0560  0.4393  4.9069 
## 
## Random effects:
##  Groups             Name        Variance Std.Dev.
##  Sample_Year:LakeID (Intercept) 45.19    6.722   
##  LakeID             (Intercept) 13.37    3.656   
##  Residual                       21.71    4.659   
## Number of obs: 623, groups:  Sample_Year:LakeID, 81; LakeID, 16
## 
## Fixed effects:
##                      Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)           10.2757     2.4593 15.1672   4.178  0.00079 ***
## DreissenidsUninvaded   6.3058     2.5638 19.3133   2.460  0.02350 *  
## Percent_Ag             0.1131     0.0925 13.3744   1.223  0.24247    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) DrssnU
## DrssndsUnnv -0.760       
## Percent_Ag  -0.732  0.461
plot(redOWTC)

qqPlot(resid(redOWTC))

## 235 212 
## 100  88

Shoreline Bloom Chlorophyll a

-Sample_Year removed for low variance

redSBChl<-lmer(log(ESF_Chl.a_ug.L) ~ Dreissenids  + Percent_Ag + (1|Sample_Month) + (1|LakeID) , data=redSBCSLAP)

summary(redSBChl)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(ESF_Chl.a_ug.L) ~ Dreissenids + Percent_Ag + (1 | Sample_Month) +  
##     (1 | LakeID)
##    Data: redSBCSLAP
## 
## REML criterion at convergence: 491
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.78450 -0.49874  0.03112  0.62808  2.18538 
## 
## Random effects:
##  Groups       Name        Variance Std.Dev.
##  LakeID       (Intercept) 3.3489   1.8300  
##  Sample_Month (Intercept) 0.2952   0.5434  
##  Residual                 4.2813   2.0691  
## Number of obs: 110, groups:  LakeID, 9; Sample_Month, 6
## 
## Fixed effects:
##                       Estimate Std. Error        df t value Pr(>|t|)   
## (Intercept)           6.452488   1.826561 13.218613   3.533  0.00359 **
## DreissenidsUninvaded -0.842448   1.364656 22.383307  -0.617  0.54324   
## Percent_Ag            0.000857   0.055419  8.252143   0.015  0.98803   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) DrssnU
## DrssndsUnnv -0.729       
## Percent_Ag  -0.859  0.532
plot(redSBChl)

qqPlot(resid(redSBChl))

##  164 1024 
##   18   97

Shoreline Bloom Microcystin

-update 03/08 boundary (singular) fit Removed random effect of Sample_Month with 0.00 variance to resolve warning.

-update 06/05 adding continuous variable of TN:TP as a fixed effect

-removed (LakeID:Sample_Year) because low variance

Extract average TN:TP values for each lake and year

#Extracting average annual TP for each lake 
library(plyr)
redavgTNTP<-ddply(redOWCSLAP, c("LakeID", "Sample_Year"), summarize, 
             Mean = mean(TN_TP, na.rm=TRUE))
colnames(redavgTNTP)[colnames(redavgTNTP)=="Mean"] <- "TN_TP"

#Merge these values to the SBCSLAP df 
redSBCSLAP<-redSBCSLAP[,c(1:52, 54)]
redSBCSLAP<-merge(redSBCSLAP, redavgTNTP, by=c("LakeID", "Sample_Year"), all.x=TRUE, all.y=FALSE)
redSBmicro<-lmer(log(ESF_Microcystin_ug.L) ~ Dreissenids + TN_TP  + Percent_Ag + (1|Sample_Year) + (1|LakeID), data=redSBCSLAP)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## unable to evaluate scaled gradient
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge: degenerate Hessian with 1 negative eigenvalues
summary(redSBmicro)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(ESF_Microcystin_ug.L) ~ Dreissenids + TN_TP + Percent_Ag +  
##     (1 | Sample_Year) + (1 | LakeID)
##    Data: redSBCSLAP
## 
## REML criterion at convergence: 144.2
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.28693 -0.54755  0.04839  0.58461  1.60177 
## 
## Random effects:
##  Groups      Name        Variance Std.Dev.
##  Sample_Year (Intercept) 6.371425 2.52417 
##  LakeID      (Intercept) 0.001968 0.04436 
##  Residual                2.346597 1.53186 
## Number of obs: 35, groups:  Sample_Year, 5; LakeID, 3
## 
## Fixed effects:
##                        Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)           7.402e+00  3.071e+00  6.141e-04   2.410    0.997
## DreissenidsUninvaded -1.127e+00  1.317e+00  8.937e-05  -0.855    1.000
## TN_TP                -5.540e-02  6.130e-02  3.539e+00  -0.904    0.423
## Percent_Ag           -1.818e-02  6.826e-02  2.738e-04  -0.266    0.999
## 
## Correlation of Fixed Effects:
##             (Intr) DrssnU TN_TP 
## DrssndsUnnv -0.830              
## TN_TP       -0.261  0.053       
## Percent_Ag  -0.623  0.714 -0.512
## convergence code: 0
## unable to evaluate scaled gradient
## Model failed to converge: degenerate  Hessian with 1 negative eigenvalues
plot(redSBmicro)

qqPlot(resid(redSBmicro))

## 31 22 
## 19 16